package StudyCode.summary.mycollection;

import java.util.Arrays;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CalculateExponentiationForAllValuesInAnArrayOfDoublesByAGivenExponent {
	public static void main(String[] argv) {
		double[] array = new double[]{34.45, 35.45, 36.67, 37.78,
				37.0000, 37.1234, 67.2344, 68.34534, 69.87700};
		float exponent = 2.45678f;
		System.out.println("计算数组中每个元素的 2.45678 幂:");
		System.out.println(Arrays.toString(exponentiateAll(array, exponent)));
	}

	public static double[] exponentiateAll(double[] array, float exponent) {

		for (int i = 0; i < array.length; i++) {
			array[i] = Math.pow(array[i], exponent);
		}

		return array;
	}
}
